import axios from 'axios'
import { ElMessage } from 'element-plus'

const service = axios.create({
  baseURL: 'http://192.168.251.13:5000/api',
  timeout: 5000,
  withCredentials: true
})


// 请求拦截器
service.interceptors.request.use(
  config => {
    console.log('请求配置:', {
      完整URL: config.baseURL + config.url,
      方法: config.method,
      数据: config.data
    })
    return config
  },
  error => {
    return Promise.reject(error)
  }
)

// 响应拦截器
service.interceptors.response.use(
  response => {
    return response
  },
  error => {
    ElMessage.error(error.message)
    return Promise.reject(error)
  }
)

export default service